<?php
namespace heihei\libs\weixin\mp;

use Yii;
use heihei\libs\weixin\baseApi;
use heihei\helpers\HttpClientHelper;

/**
 * Sns操作类
 */
class Sns extends BaseMP{
  public function jscode2session($jsCode, $grantType = 'authorization_code'){
    $url = 'https://api.weixin.qq.com/sns/jscode2session?';
    $params = [
      'appid' => $this->appid,
      'secret' => $this->secret,
      'grant_type' => $grantType,
      'js_code' => $jsCode
    ];
    $url = $url . http_build_query($params);
    return HttpClientHelper::getJson($url);
  }
}